package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.utils.HttpClientUtil;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/admin/shop")
@RestController
@Slf4j
public class ShopController {
    ///admin/shop/{status}
    @Autowired
    private RedisTemplate redisTemplate;
    @PutMapping("/{status}")
    @ApiOperation("设置营业状态")
    public Result setStatus(@PathVariable Integer status){
        log.info("设置营业状态为：{}",status == 1 ? "营业" : "非营业");
        redisTemplate.opsForValue().set("SHOP_STATUS" , status);
        return Result.success();
    }
    @GetMapping("/status")
    @ApiOperation("得到营业状态")
    public Result<Integer> getStatus(){
        Integer integer = (Integer)redisTemplate.opsForValue().get("SHOP_STATUS");
        log.info("当前营业状态为：{}",integer);
        return Result.success(integer);
    }


}
